// created on 26.07.2007 at 14:55

using Gtk;
using System;
using System.Text.RegularExpressions;
using Designer;

public class ResNameEntry : Entry
{
	public ResNameEntry()
	{
		this.FocusOutEvent += FocusOut;
		validtext = "";
	}
	string validtext;
	public string ValidText
	{
		get
		{
			return validtext;
		}
		set
		{
			validtext = value;
			Text = validtext;
		}
	}
	protected virtual void FocusOut(object o, Gtk.FocusOutEventArgs args)
	{
		if(IsValid(Text))
		validtext = Text;
		else
		Text = validtext;
	}
	public static bool IsValid(string text)
	{
		return Regex.IsMatch(text,"^[_a-zA-Z]+[_a-zA-Z0-9]*$") && !ResourceMgr.Instance.ResourceNameExists(text);
	}
}